<template>
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <swiper-slide
        v-for="item of list"
        :key="item.index"
        class="swiper-no-swiping"
      >
        <keep-alive>
          <component :is="item.component"></component>
        </keep-alive>
      </swiper-slide>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import one from "../subpages/recommend/recommend";
import two from "../subpages/bbs/bbs";
export default {
  name: "Swiper",
  components: {
    one,
    two,
  },
  data() {
    return {
      swiperOptions: {},
      list: [
        { path: "tabone", component: one, index: 1 },
        { path: "tabtwo", component: two, index: 2 },
      ],
    };
  },
  mounted() {
    let mySwiper = new Swiper(".swiper-container", this.swiperOptions);
    this.$root.bus.$on("tabSwitch", (index) => {
      mySwiper.slideTo(index, 0, false);
    });

    mySwiper.on("slideChange", () => {
      this.$root.bus.$emit("pageSwitch", mySwiper.activeIndex);
    });
  },
};
</script>
<style lang="scss" scoped>
</style>